/*
 * Course:    CS 590 Web Services
 * Semseter:  Spring 2009
 * Professor: Sedlemeyer
 * Project:   CHEAT (Code Help Educational Assignment Tool)
 * Due Date:  May 1, 2009
 * Team:      Sarcasm
 *            (Baker, Jason; Mitchell, Robin; Shie, Keith)
 */

package cheat.entities.keys;

import cheat.entities.AssignmentAcl;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * Holds the composite primary key for the {@linkplain AssignmentAcl} entity.
 *
 * @author Keith Shie
 */
@Embeddable
public class AssignmentAclPK implements Serializable {
  @Basic(optional = false)
  @Column(name = "uuid", nullable = false)
  private int uuid;
  @Basic(optional = false)
  @Column(name = "acl", nullable = false, length = 20)
  private String acl;

  public AssignmentAclPK() {
  }

  public AssignmentAclPK(int uuid, String acl) {
    this.uuid = uuid;
    this.acl = acl;
  }

  public int getUuid() {
    return uuid;
  }

  public void setUuid(int uuid) {
    this.uuid = uuid;
  }

  public String getAcl() {
    return acl;
  }

  public void setAcl(String acl) {
    this.acl = acl;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (int) uuid;
    hash += (acl != null ? acl.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof AssignmentAclPK)) {
      return false;
    }
    AssignmentAclPK other = (AssignmentAclPK) object;
    if (this.uuid != other.uuid) {
      return false;
    }
    if ((this.acl == null && other.acl != null) || (this.acl != null && !this.acl.equals(other.acl))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "cheat.entities.AsgnAclPK[uuid=" + uuid + ", acl=" + acl + "]";
  }

}
